/**
 * 
 */
package top.ieei.demo.ftp.server;

import java.io.IOException;
import java.io.InputStream;
import java.util.HashMap;
import java.util.Map;
import java.util.Properties;

/**
 * 静态对象类
 * @author Forrest.Tse
 *
 */
public final class StaticObj
{
	/**
	 * 公共配置参数Map
	 */
	private static Map<String, Object> configMap = new HashMap<String, Object>();
	
	/**
	 * 系统配置参数
	 */
	private static Properties properties = new Properties();
	
	// 静态初始化
	static
	{
		InputStream is = null;
		try
		{
			is = ClassLoader.getSystemResourceAsStream("config.properties");
			if(null == is)
			{
				System.out.println("获取配置信息时错误：系统配置文件config.properties不存在。");
			}
			else 
			{
				properties.load(is);
			}
		}
		catch (Exception e)
		{
			e.printStackTrace();
		}
		finally
		{
			if (null != is)
			{
				try
				{
					is.close();
				}
				catch (IOException e)
				{
					e.printStackTrace();
				}
			}
		}
	}
	
	/**
	 * 获取公共配置参数Map
	 * @return Map<String, Object>
	 */
	public static Map<String, Object> getConfigMap()
	{
		return configMap;
	}
	
	/**
	 * 获取系统配置参数
	 * @return Properties
	 */
	public static Properties getProperties()
	{
		return properties;
	}
	
	/**
	 * 私有构造方法
	 */
	private StaticObj()
	{
		
	}
}
